<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue/dist/vue.js"></script>

</head>

<body>
  <div id="app">
    <Foo v-model="title"></Foo>
  </div>

  <script>

    // v-model
    // 绑定的值对应到props中的 value
    // 触发事件是 input 事件
    Vue.component("Foo", {
      props: ["value"],
      // 模板
      template: `<div>
          Foo
          <p>{{value}}</p>
          <button @click="changeTitle">按钮</button>
        </div>`,
      methods: {
        changeTitle() {
          this.$emit("input", "刘晓佳")
        }
      }
    })

    const vm = new Vue({
      el: "#app",
      data: {
        title: "b"
      },
      methods: {
        // handleChangeTitle() {
        //   this.title = "c"
        // }
      }
    })
  </script>
</body>

</html>
